package Gui.Simulator;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

import simulator.labyrinth.Labyrinth;
import simulator.robot.Simulator;
import simulator.robot.SimulatorListener;


public class SimulatorGui {

	private JFrame frame;
	private Board panel;

	/**
	 * Create the application.
	 */
	public SimulatorGui() {
		initialize();
		this.frame.setVisible(true);
	}
	
	public void setLabyrinth(Labyrinth labyrinth) {
		this.panel.setLabyrinth(labyrinth);
	}
	
	public void setSimulator(Simulator simulator)
	{
		this.panel.setSimulator(simulator);
	}
	
	public void setSimulatorListener(SimulatorListener listener) {
		this.panel.setSimulatorListener(listener);
	}
	

	public void setSensorAngle(double angle){
		panel.setSensorOffset(angle);
	}
	public void setVisible(boolean visible)
	{
		this.frame.setVisible(visible);
	}
	
	/**
	 * Initialize the contents of the frame.
	 */
	
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 713, 568);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JScrollPane scrollPane = new JScrollPane();
		panel = new Board(scrollPane);
		panel.setBounds(0,0, 20000,20000);
		panel.setPreferredSize(new Dimension( 20000,20000));
		scrollPane.setViewportView(panel);

		frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
		
		
		// Disable scrollbar
		scrollPane.getActionMap().put("unitScrollRight", new AbstractAction(){
		    @Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrollPane.getActionMap().put("unitScrollDown", new AbstractAction(){
		    @Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrollPane.getActionMap().put("unitScrollLeft", new AbstractAction(){
		    @Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrollPane.getActionMap().put("unitScrollUp", new AbstractAction(){
		    @Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrollPane.getHorizontalScrollBar().setEnabled(false);
		scrollPane.getVerticalScrollBar().setEnabled(false);
		
		
	
		
		//frame.getContentPane().add(panel, BorderLayout.CENTER);
		
		
	}

	public void repaint() {
		panel.repaint();		
	}
	

}
